<?php
declare (strict_types = 1);

namespace app\common\model\User;

use think\Model;

/**
 * @mixin 充值表
 */
class Pay extends Model
{
    // 指定的数据表
    protected $table = 'pre_pay';

    // 自动写入时间
    protected $autoWriteTimestamp = true;

    // 创建时间
    protected $createTime = 'createtime';

    // 更新时间
    protected $updateTime = false;

    
    protected $append = [
        'status_text', //多张
    ];

    protected function getStatusTextAttr($value, $data)
    {
        $status = $data['status'];
        $text = '';

        switch($status)
        {
            case 0:
                $text = '未审核';
                break;
            case 1:
                $text = '已审核';
                break;
            case 2:
                $text = '审核未通过';
                break;
            default:
                $text= '未知状态';
        }

        return $text;
    }

    public function user()
    {
        return $this->belongsTo('app\common\model\User\User','userid','id');
    }

    public function admin()
    {
        return $this->belongsTo('app\common\model\Admin','adminid','id');
    }
    
}
